We are migrating the bug tracker to github Issues. This is now the preferred way to report NASM bugs.

Self-registration is disabled due to spam issue (mail gorcunov@gmail.com or hpa@zytor.com to create an account)

Bug 3392628 - %ifnidn triggering for same content under certain circumstances
Summary: %ifnidn triggering for same content under certain circumstances
Status: OPEN
Alias: None
Product: NASM
Classification: Unclassified
Component: Assembler (show other bugs)
Version: 2.15.xx
Hardware: All All
: Medium minor
Assignee: nobody
URL:
Depends on:
Blocks:
 
Reported: 2019-10-26 03:55 PDT by E. C. Masloch
Modified: 2019-10-28 01:26 PDT (History)
5 users (show)

Obtained from: Built from git using configure
Generated by: ---
Bug category:
Observed for: ---
Regression: ---
Regression since:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description E. C. Masloch 2019-10-26 03:55:49 PDT
A certain combination of twice defining a variable with %assign, passing that variable through %xdefine, and then passing one of the variables into a multi-line macro parameter, results in differing opinions on whether the variables are the same for %ifnidn, between an old NASM and the newest NASM (which is https://repo.or.cz/nasm.git/commitdiff/e91f5cc1322eed4da0de81656276e021bf352c3d built from git using configure).

$ nasm -v
NASM version 2.15rc0 compiled on Oct 24 2019
$ oldnasm -v
NASM version 2.12.02 compiled on Aug 10 2019
$ cat test4.asm 

%push

%assign ?var -6

 %xdefine %$labellist ?var
%assign ?var -6

	%macro mac5 1-*
%ifnidn %1, %$check
 %warning false 1=%1 check=%$check
%else
 %warning true 1=%1 check=%$check
%endif
	%endmacro

%xdefine %$check ?var
	mac5 %$labellist
%pop
$ echo "nasm:"; nasm test4.asm; echo "oldnasm:"; oldnasm test4.asm 
nasm:
test4.asm:18: warning: true 1=-6 check=-6 [-w+user]
test4.asm:13: ... from macro `mac5' defined here
oldnasm:
test4.asm:18: warning: (mac5:2) false 1=-6 check=-6
test4.asm:11: ... from macro `mac5' defined here
$ 


I already simplified my test case somewhat, originally it was the conditional at https://hg.ulukai.org/ecm/lmacros/file/67a2ee517d8e/lmacros2.mac#l666 which failed in test case 015 on older NASM.

Here's a workaround that I will apply to my macro package to support older NASM versions:


$ cat test5.asm 

%push

%assign ?var -6

 %xdefine %$labellist ?var
%assign ?var -6

	%macro mac5 1-*
%ifnidn %1, %$check
 %ifnnum %1
  %warning false 1=%1 check=%$check
 %elifnnum %$check
  %warning false 1=%1 check=%$check
 %elifn %1 == %$check
  %warning false 1=%1 check=%$check
 %else
 %warning true2 1=%1 check=%$check
 %endif
%else
 %warning true1 1=%1 check=%$check
%endif
	%endmacro

%xdefine %$check ?var
	mac5 %$labellist
%pop
$ echo "nasm:"; nasm test5.asm; echo "oldnasm:"; oldnasm test5.asm 
nasm:
test5.asm:26: warning: true1 1=-6 check=-6 [-w+user]
test5.asm:21: ... from macro `mac5' defined here
oldnasm:
test5.asm:26: warning: (mac5:9) true2 1=-6 check=-6
test5.asm:18: ... from macro `mac5' defined here
$ 


Here's another test case which fails for both versions of NASM. I consider this as an error, which applies to both versions.


$ cat test6.asm

%push
%assign ?var -6

	%macro mac5 1-*
%ifnidn %1, %$check
 %warning false 1=%1 check=%$check
%else
 %warning true 1=%1 check=%$check
%endif
	%endmacro

%xdefine %$check ?var
	mac5 -6
%pop
$ echo "nasm:"; nasm test6.asm; echo "oldnasm:"; oldnasm test6.asm 
nasm:
test6.asm:14: warning: false 1=-6 check=-6 [-w+user]
test6.asm:7: ... from macro `mac5' defined here
oldnasm:
test6.asm:14: warning: (mac5:2) false 1=-6 check=-6
test6.asm:7: ... from macro `mac5' defined here
$
Comment 1 E. C. Masloch 2019-10-26 04:01:22 PDT
Workaround added to my macro collection in https://hg.ulukai.org/ecm/lmacros/rev/61cdbc252795
Comment 2 H. Peter Anvin 2019-10-27 19:35:46 PDT
It seems to me that the current behavior is the more correct and that this amounts to a bug fixed. Any reason to take any action in current NASM?
Comment 3 E. C. Masloch 2019-10-28 01:26:56 PDT
test6.asm should result ib "true" but doesn't yet.